package selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

public class Page {

	String baseUrl;
	public static WebDriver driver;	 
	
	public static void setDriver(WebDriver drv)
	{
		driver = drv;
	}
	
	protected void openPage() {
		driver.get(baseUrl);
	}

	protected String getLinkText(String linkName) {
		return driver.findElement(By.linkText(linkName)).getText();
	}

	public void clickLink(String linkName) {
		driver.findElement(By.linkText(linkName)).click();
	}

	public void clickElementByXpath(String xpath) {
		driver.findElement(By.xpath(xpath)).click();
	}

	public void fillFieldByXpath(String xpath, String value) {
		driver.findElement(By.xpath(xpath)).sendKeys(value);
	}
	
	public boolean textExistsInPageSource(String text) {
		return driver.getPageSource().contains(text);
	}
		
}